﻿<?php
session_start();

if (!isset($_SESSION['login']) && !$_SESSION['login'] == true) {
	header ("Location: index.php");
}

include 'config.php';

mysqli_set_charset($con, 'utf8');

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="scripts/jquery.tablesorter.js"></script>
<title>Sales Makeover</title>
</head>

<body>
	<div class="bodyLeft" id="bodyLeft">
		<?php include("menu.html"); ?>
	</div>
	<div class="bodyRight" id="bodyRight">
		<div class="container_head">
			<?php include("header.html"); ?>
		</div>
		<div class="container" id="container">
			<div class="content">
				
				<center>
				<img border="0" src="content\icons\Buttons\step_1_inactive.png" width="50">
				<img border="0" src="content\icons\Buttons\step_2_active.png" width="50">
				<br>
				<br>
				</center>
				
				
				<div style='text-align:left;width:90%;margin-left:auto;margin-right:auto;'>Följ dessa tre steg för att skapa din rekommendation. Fält markerade med stjärna är obligatoriska</div><br/>
				
				
				<form id="create_Innovation_step_1" class="create_Innovation_step_1"  method="post" action="createNewInnovation.php" accept-charset="UTF-8" onsubmit="return validateForm()">
					<input type="hidden" name="Customer" value="<?php if(isset($_POST['Customer'])) { echo $_POST['Customer']; }?>">
					<input type="hidden" name="Project" value="<?php if(isset($_POST['Project'])) { echo $_POST['Project']; }?>">
					<input type="hidden" name="BusinessValue" value="<?php if(isset($_POST['BusinessValue'])) { echo $_POST['BusinessValue']; }?>">
					<input type="hidden" name="OwnerRole" value="<?php if(isset($_POST['OwnerRole'])) { echo $_POST['OwnerRole']; }?>">
					<input type="hidden" name="Contact" value="<?php if(isset($_POST['Contact'])) { echo $_POST['Contact']; }?>">
					
					<div class="createInnovation2Label">*Rekommendation / Idé</div>
					<input type="text" name="Recommendation" onfocus="if(this.value == '*Rekommendation / Idé') { this.value = ''; }" onblur="if(this.value == '') { this.value = '*Rekommendation / Idé'; }" value="*Rekommendation / Idé">
					<div class="createInnovation2Label">*Kundens problem</div>
					<input type="text" name="Problem" onfocus="if(this.value == '*Kundens problem') { this.value = ''; }" onblur="if(this.value == '') { this.value = '*Kundens problem'; }" value="*Kundens problem">
					<br/>
					<div class="createInnovation2Label">*Lösning</div>
					<input type="text" name="Solution" onfocus="if(this.value == '*Lösning') { this.value = ''; }" onblur="if(this.value == '') { this.value = '*Lösning'; }" value="*Lösning">
					<div class="createInnovation2Label">*Värde för kunden</div>
					<input type="text" name="CustomerValue" onfocus="if(this.value == '*Värde för kunden') { this.value = ''; }" onblur="if(this.value == '') { this.value = '*Värde för kunden'; }" value="*Värde för kunden">
					<br/>
					<div class="createInnovation2Label">*Nästa steg</div>
					<select name="NextStep">
						<option selected disabled>Nästa steg</option>
						<?php 
						$sql = "SELECT * FROM Innovation_NextStep";
						$result = mysqli_query($con,$sql);
			
						while($row = mysqli_fetch_array($result))
						{
							echo "<option value=\"" . $row['ID'] . "\">" . $row['Value'] . "</option>";
						}
						
						?>
					</select>
					<div class="createInnovation2Label">*Tidsplan</div>
					<select name="TimeFrame">
						<option selected disabled>Tidsplan</option>
						<?php 
						$sql2 = "SELECT * FROM Innovation_TimeFrame";
						$result2 = mysqli_query($con,$sql2);
			
						while($row2 = mysqli_fetch_array($result2))
						{
							echo "<option value=\"" . $row2['ID'] . "\">" . $row2['Value'] . "</option>";
						}
						
						?>
					</select>
					
					<input type="submit" value="Skicka">
					
				</form>
				
			</div>
		</div>
	</div>
</body>

</html>
<script type="text/javascript" charset="UTF-8">
	function validateForm()
	{
		var RecommendationVal = document.forms["create_Innovation_step_1"]["Recommendation"].value;
		if(RecommendationVal == "*Rekommendation / Idé")
		{
			alert("Rekommendation / Idé kan inte vara tom");
			return false;
		}	
		var ProblemVal = document.forms["create_Innovation_step_1"]["Problem"].value;
		if(ProblemVal == "*Kundens problem")
		{
			alert("Kundens problem kan inte vara tom");
			return false;
		}
		var SolutionVal = document.forms["create_Innovation_step_1"]["Solution"].value;
		if(SolutionVal == "*Lösning")
		{
			alert("Lösning kan inte vara tom");
			return false;
		}
		var CustomerValueVal = document.forms["create_Innovation_step_1"]["CustomerValue"].value;
		if(CustomerValueVal == "*Värde för kunden")
		{
			alert("Värde för kunden kan inte vara tom");
			return false;
		}
		var NextStepVal = document.forms["create_Innovation_step_1"]["NextStep"].value;
		if(NextStepVal == "Nästa steg")
		{
			alert("Välj nästa steg i projektet");
			return false;
		}
		var TimeFrameVal = document.forms["create_Innovation_step_1"]["TimeFrame"].value;
		if(TimeFrameVal == "Tidsplan")
		{
			alert("Välj tidsplan");
			return false;
		}
	};
</script>